﻿using System;
using UnityEngine;

namespace WentStateMachine
{
    [Serializable]
    public class Layer
    {

        private string _name;
        public string name
        {
            get
            {
                return _name;
            }
            set
            {
                nameHash = Helper.ScriptingStringToCRC32(value);
                _name = value;
            }
        }

        [SerializeField] private int _nameHash;
        public int nameHash {
            get
            {
                return _nameHash;
            }
            set
            {
                _nameHash = value;
            }
        }

        [SerializeField] private StateMachine _stateMachine;
        public StateMachine stateMachine {
            get {
                return _stateMachine;
            }
            set {
                _stateMachine = value;
            } 
        }

        public void Init(StateMachineController controller, int index)
        {
            if(stateMachine)
            {
                stateMachine = ScriptableObject.Instantiate(_stateMachine);
                stateMachine.Init(controller, index);
            }
        }
    }
}
